package acm.天梯赛练习2;

import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int count = sc.nextInt();
        while (count-- > 0) {
            double Y = sc.nextDouble();
            double Q = sc.nextDouble();
            double e = sc.nextDouble();
            double f = sc.nextDouble();
            double g = sc.nextDouble();
            System.out.println(String.format("%.1f",Y*(1+e/100*Q/365)*(1+g/100)));
            System.out.println(String.format("%.1f",Y*(1+f/100*(Q+365)/365)));
        }
    }
}
